{include file="common/pc/header" title="账号信息修改" /}

<form class="layui-form" action="" method="post" enctype="multipart/form-data">
    <div class="layui-form-item">
        <label class="layui-form-label">登录名</label>
        <div class="layui-input-inline">
            <input type="text" autocomplete="off" class="layui-input readonly" value="{$user.username}" readonly disabled/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-inline">
            <input type="text" autocomplete="off" class="layui-input readonly" value="{$user.showname}" readonly disabled/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">头像</label>
        <div class="layui-input-inline">
            {d:up type="image" field="avatar" value="$user.avatar" btn="false"}浏览图片{/d:up}
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">现登录密码</label>
        <div class="layui-input-inline">
            <input type="password" name="password" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">新登录密码</label>
        <div class="layui-input-inline">
            <input type="password" name="newPassword" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">新密码确认</label>
        <div class="layui-input-inline">
            <input type="password" name="newPassword2" lay-verify="newPassword2" placeholder="请输入密码" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">确保跟上面输入的密码一致</div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="profileSubmit"> 保 存</button>
        </div>
    </div>
</form>

<script>
    layui.use(['form'], function () {
        var $ = layui.jquery, form = layui.form;

        form.verify({
            newPassword2: function (value, item) { //value：表单的值、item：表单的DOM对象
                if (value && !$("input[name='password']").val()) {
                    return '请输入现登录密码';
                }
                if (value && value != $("input[name='newPassword']").val()) {
                    return '两次输入的新密码不同，请重新输入';
                }
                if (value && value.length < 5) {
                    return '密码长度过短，必须大于5个字符';
                }
            }
        });
    });
</script>

{include file="common/pc/footer"/}